<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8" />
    <title>Document</title>
    <style></style>
  </head>
  <body>
    <div>
      <h1>字面量与构造式</h1>
    </div>
    <script>
      //引用类型--使用字面量的函数优于使用构造式的,但是差异不大
      let test = () => {
        let obj = new Object();
        obj.name = "xjq";
        obj.age = 22;
        obj.slogan = "123456";
        return obj;
      };

      let test = () => {
        let obj = {
          name: "xjq",
          age: 22,
          slogan: "123456",
        };
        return obj;
      };

      //   test();
      console.log(test());

      //基本数据类型--使用字面量的优于使用构造式的,而且差异较大
      var str1 = "xjq";
      var str2 = new String("xjq");
    </script>
  </body>
</html>
